<extend name="Public/base"/>


<block name="body">

    <script type="text/javascript" src="__STATIC__/jquery-1.10.2.min.js"></script>
    <![endif]-->
    <!--[if gte IE 9]><!-->
    <script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
    <!--<![endif]-->

    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>商品详情</h2>
    </div>
    <form action="{:U('goods_add')}" method="post" class="form-horizontal">

        <div class="form-item">
            <label class="item-label">商品名称<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$info.name}">
            </div>
        </div>


        <div class="form-item">
            <label class="item-label">商品价格<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="price" value="{$info.price}">
            </div>
        </div>

        <input type="hidden" class="text input-large" name="id" value="{$info.id}">



        <div class="form-item">
            <label class="item-label">商品库存<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="num" value="{$info.num}">
            </div>
        </div>


              <div class="form-item">
            <label class="item-label">商品分类<span class="check-tips"></span></label>
            <div class="controls" id="cat_box">
                <select id="province" name="cate_id">
                    <option>请选择</option>
                    <volist name="cates" id="vo" >
                        <option value="{$vo.id}"<if condition="$vo['id'] eq $info['cate_id']">selected</if>>{$vo.title}</option>
                    </volist>
                </select>
            </div>
        </div>


       

            <label class="item-label">
                商品分类<span class="check-tips"></span>
            </label>
            <div class="controls">
                <label class="inline radio"><input type="radio" name="type" value="1" <if condition="$info['type'] eq 1">checked</if>>实物</label>
                <label class="inline radio"><input type="radio" name="type" value="2" <if condition="$info['type'] eq 2">checked</if>>虚物</label>
            </div>


                         <div class="controls">
                                <label class="item-label">商品图片</label>
                                <input type="file" id="upload_picture">
                                <input type="hidden" name="img" id="icon" value="{$info['img']|default=''}"/>
                                <div class="upload-img-box">
                                    <notempty name="info['img']">
                                        <div class="upload-pre-item"><img src="{$info['img']|get_cover='path'}"/></div>
                                    </notempty>
                                </div>
                            </div>
                            <script type="text/javascript">
                                //上传图片
                                /* 初始化上传插件 */
                                $("#upload_picture").uploadify({
                                    "height"          : 30,
                                    "swf"             : "__STATIC__/uploadify/uploadify.swf",
                                    "fileObjName"     : "download",
                                    "buttonText"      : "上传图片",
                                    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                                    "width"           : 120,
                                    'removeTimeout'   : 1,
                                    'fileTypeExts'    : '*.jpg; *.png; *.gif;',
                                    "onUploadSuccess" : uploadPicture,
                                    'onFallback' : function() {
                                        alert('未检测到兼容版本的Flash.');
                                    }
                                });
                                function uploadPicture(file, data){
                                    var data = $.parseJSON(data);
                                    var src = '';
                                    if(data.status){
                                        $("#icon").val(data.id);
                                        src = data.url || '__ROOT__' + data.path;
                                        $("#icon").parent().find('.upload-img-box').html(
                                                '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                                        );
                                    } else {
                                        updateAlert(data.info);
                                        setTimeout(function(){
                                            $('#top-alert').find('button').click();
                                            $(that).removeClass('disabled').prop('disabled',false);
                                        },1500);
                                    }
                                }
                            </script>


        <div class="form-item">
            <label class="item-label">商品介绍<span class="check-tips"></span></label>
            <label class="textarea">
                <textarea name="desc">{$info.desc}</textarea>
                {:hook('adminArticleEdit')}
            </label>

        </div>


        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">

    <script type="text/javascript">
        //导航高亮
        highlight_subnav("{:U('Manage/goods')}");
        //获取市
        $("#province").change(function (){
            var upid=$(this).val();
            $("#district").find('.de').remove();
            $("#city").find('.de').remove();
            url="{:U('city')}";
            $.post(url,{upid:upid},function(res){
                $('#city').html(res);
            });
        })
        $('#city').change(function (){
            var upid=$(this).val();
            url="{:U('district')}";
            $.post(url,{upid:upid},function(res){
                $('#district').html(res);
            });
        });
    </script>
</block>
